import '@babel/polyfill'
import 'mutationobserver-shim'
import Vue from 'vue'
import './plugins/bootstrap-vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
import ElementUI from 'element-ui'
import './assets/js/tx1.js'
import Articles from './components/Articles'
import Articles1 from './components/Articles1'
import DescrTitle from './components/DescTitle'
import Intro from './components/Intro'
import LogoImg from './components/LogoImg'
import ArList from './components/ArList'
import CopyInfo from './components/CopyInfo'
import Middle from './components/Middle'
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import 'prismjs/prism'
import 'prismjs/themes/prism.css'
import animated from 'animate.css'
Vue.use(animated)
Vue.use(VueQuillEditor)
Vue.use(ElementUI)
Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999
  }
})
// 设置浏览器标题
Vue.directive('title', {
  inserted: function (el, binding) {
    document.title = el.dataset.title
  }
})
Vue.component('articles', Articles)
Vue.component('articles1', Articles1)
Vue.component('descr-title', DescrTitle)
Vue.component('article-intro', Intro)
Vue.component('logo-img', LogoImg)
Vue.component('article-list', ArList)
Vue.component('copy-info', CopyInfo)
Vue.component('middle', Middle)
Vue.use(VueAxios, axios)
axios.defaults.baseURL = 'http://blog.66zx.top/api/'
// axios.defaults.baseURL = 'http://localhost:8090/api/'
let loading
function startLoading () {
  // 如果根实例设为变量VUE var VUE = new Vue({}) 也可写成下面的
  // loading = VUE.$loading({
  //   lock: true,
  //   text: "拼命加载中...",
  //   background: 'rgba(0,0,0,0.2)'
  // })
  loading = ElementUI.Loading.service({
    lock: true,
    text: '数据加载中...',
    background: 'rgba(0,0,0,0.2)'
  })
}

function endLoading () {
  loading.close()
}
axios.interceptors.request.use(
  config => {
    config.timeout = 6000
    startLoading()
    return config
  },
  error => {
    return Promise.reject(error)
  }
)
axios.interceptors.response.use(
  response => {
    // 定时刷新access-token
    endLoading()
    return response
  },
  error => {
    return Promise.reject(error)
  }
)
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
